#pragma once

#include "MapZone.h"
#include <string>

namespace Tmpl {

// Positional Map
typedef unsigned char ZonesCountType;
#define MAX_TEXTURES_PER_POS 8
struct MapPosTexture
{
	unsigned char texId;
	unsigned char value;
};
class MapPos
{
public:
	float height;
	ZonesCountType zone;
	MapPosTexture textures[MAX_TEXTURES_PER_POS];

	void SetNormal(const Vec3f& n);
	Vec3f GetNormal() const;
private:
	unsigned int mNormal;
};

// The map itself
class Map
{
public:
	Map();
	~Map();

	void GenerateMap(int seed, ZonesCountType zoneCount, int size);

	// zones
	void AddZoneType(MapZoneType* zoneType);
	MapZone* GetZoneAtPos(Vec2f pos);
	MapZone* GetZoneById(ZonesCountType idx) const {return mZones[idx];}

	// positional
	float GetHeightAtPos(Vec2f pos);
	MapPos* GetMapPos(int x, int y);
	MapPos& GetMapPosSafe(int x, int y); // returns the last map tile if you go outside of boundaries

	int GetSeed()const {return mSeed;}
	int GetSize()const {return mMapSize;}

	int GetTextureCount() const { return mTextures.size(); }
	const char* GetTexture(int id) const { return mTextures[id].c_str();}

private:
	// Map Data
	int mSeed;
	int mMapSize;
	MapPos* mMap;

	// Zone Data
	std::deque<MapZoneType*> mZoneTypes;
	ZonesCountType mZoneCount;
	MapZone** mZones;

	// Tex Data
	std::deque<std::string> mTextures;
};

}; // namespace Tmpl